<form id="searchform" name="searchform" action="<?php echo base_url("index.php/caseinfo/searchinfo")?>" method="post">
      <fieldset>
      <legend>Search Condition</legend>
      <input type="hidden" name="currentPage" id="currentPage" value="0"/>
      <table class="nostyle">
        <tr>
          <td style="width:120px;">Case Name:</td>
          <td><input type="text" size="20" name="case_name" id="case_name" class="input-text" value="<?php echo isset($_POST["case_name"])?$_POST["case_name"]:"";?>" /></td>
		</tr>
	    <tr>
          <td style="width:120px;">Case Type:</td>
          <td>
          <select name="case_type" id="case_type" class="input-text"  >
          <?php 
          	$case_type = isset($_POST["case_type"])?intval($_POST["case_type"]):0;
          ?>
			<option value="0" <?php if ($case_type == 0) echo 'selected="selected" ';?>>Criminal Case</option>
			<option value="1" <?php if ($case_type == 1) echo 'selected="selected" ';?>>Civil Case</option>
		  </select> 
          </td>
        </tr>
		
		<tr>
          <td style="width:120px;">Case Status</td>
          <td>
          <select name="case_status" id="case_status" class="input-text" >
			<option value="0"  <?php $case_status = isset($_POST["case_status"])?intval($_POST["case_status"]):0;
				if ($case_status == 0) echo 'selected="selected" ';?>>Not accepted</option>
			<option value="1" <?php if ($case_status == 1) echo 'selected="selected" ';?>>Being accepted</option>
			<option value="2" <?php if ($case_status == 2) echo 'selected="selected" ';?>>Accept completed</option>
		  </select>
		  </td>
        </tr>
        
		<tr>
          <td style="width:60px;">Incident Time:</td>
          <td><input type="text" id="incident_time_begin"  
          	name="incident_time_begin" size="9"  
        	value="<?php echo isset($_POST["incident_time_begin"])?$_POST["incident_time_begin"]:"";?>"
          	readonly="readonly" class="input-text Wdate"
          	onFocus="WdatePicker({lang:'en'})" />~
          <input type="text" id="incident_time_end"  
          	value="<?php echo isset($_POST["incident_time_end"])?$_POST["incident_time_end"]:"";?>"
          	name="incident_time_end" size="9" readonly="readonly" 
          	class="input-text Wdate"  onFocus="WdatePicker({lang:'en'})" /></td>
        </tr>
        <tr>
          <td style="width:60px;">Court Date:</td>
          <td style="width:200px;">
          <input type="text" id="court_date_begin"  name="court_date_begin" 
          	size="9"  readonly="readonly" class="input-text Wdate"  
          	value="<?php echo isset($_POST["court_date_begin"])?$_POST["court_date_begin"]:"";?>"
          	onFocus="WdatePicker({lang:'en'})" />~
          <input type="text" id="court_date_end"  name="court_date_end"
          	size="9"  readonly="readonly" class="input-text Wdate"  
          	value="<?php echo isset($_POST["court_date_end"])?$_POST["court_date_end"]:"";?>"
          	onFocus="WdatePicker({lang:'en'})" /></td>
        </tr>
        <tr>
          <td style="width:120px;">Prosecutor:</td>
          <td style="width:120px;">
          <input type="text" id="prosecutor" 
          	name="prosecutor" size="26"  
          	value="<?php echo isset($_POST["prosecutor"])?$_POST["prosecutor"]:"";?>"
          	class="input-text" /></td>
        </tr>
        <tr>
          <td style="width:120px;">Defendant:</td>
          <td>
          <input type="text" id="defendant" 
          	name="defendant" size="26"  
          	value="<?php echo isset($_POST["defendant"])?$_POST["defendant"]:"";?>"
          	class="input-text" /></td>
         </tr>

        <tr>
          <td colspan="2" class="t-right"><input type="submit" class="input-submit" value="Search" /></td>
        </tr>
      </table>
      </fieldset>
      
      

</form>

<!-- Table (TABLE) -->
 <div >
      <h3 class="tit">Case Information</h3>
      <table>
        <tr>
          <th style="width:200px;">Case Name</th>
          <th style="width:200px;">Court Time</th>
          <th style="width:200px;">Incident Date</th>
          <?php 
				$tmpCI = &get_instance();
				if($tmpCI->session->userdata("usertype")== 4){
			?>
          <th style="width:80px;">Edit</th>
          <th style="width:80px;">Del</th>
          <?php }?>
        </tr>
<?php 
		$i = 0;
		if (isset($list))
		{
        foreach ($list->result_array() as $row)
		{
			?>
		 <tr <?php if ($i%2 == 1)echo 'class="bg"';?>>
			<td>
			<?php 
			echo '<a href="'.base_url("index.php/caseinfo/detail/".$row["id"]).'">'.($row["case_name"]==""?"no title":$row["case_name"])."</a>";
			?>
			</td>
			<td>
			<?php 
			echo $row["court_date"];
			?>
			</td>
			<td>
			<?php 
			echo $row["incident_time"];
			?>
			</td>
			<?php 
				$tmpCI = &get_instance();
				if($tmpCI->session->userdata("usertype")== 4){
			?>
			<td>
			<?php 
			echo '<a href="'.base_url("index.php/caseinfo/edit/".$row["id"]).'">Edit</a>';
			?>
			</td>
			
			<td>
			<?php 
			echo '<a href="'.base_url("index.php/caseinfo/delete/".$row["id"]).'">Delete</a>';
			?>
			</td>
			<?php 
				}
			
			?>
			</tr>
			
<?php 
	$i++;
		}
	}
?>

		<tr><td colspan="<?php if($tmpCI->session->userdata("usertype")== 4)
		{
			echo "5";
		}
		else 
		{
			echo "3";
		}
		?>">
			<div class="f-right" >
	      <span style="width:120px;">
	      <?php 
	      
	      	if (isset($start)&&$start>=10)
	      	{
				$prev =$start-10;
				echo '<a href="#" onclick="document.searchform.currentPage.value='.$prev.';document.searchform.submit();'
				.'">prev page</a>';
	      	}
	      	else
	      	{
	      		echo "prev page";
	      	}
	      ?>
	      </span>
	      <span style="width:120px;"><?php if (isset($start))echo ""+($num == 0?0:(intval($start)/10+1))."/".($num%10==0?$num/10:intval($num/10)+1);?>
	      </span>
	      <span style="width:120px;">
	        <?php 
	      	if (isset($start)&&$start+10<=$num)
	      	{
				$next =$start+10;
				echo '<a href="#" onclick="document.searchform.currentPage.value='.$next.';document.searchform.submit();'
				.'">Next page</a>';
	      	}
	      	else
	      	{
	      		echo "Next page";
	      	}
	      ?>
	      </span>
	      </div>
		</td></tr>
      </table>
      
 </div>
 